package cn.lonecloud.action.product;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.lonecloud.model.Product;
import cn.lonecloud.service.ProductService;
import cn.lonecloud.service.impl.ProductServiceImpl;

/**
 * 更新产品信息
 * @author lonecloud
 */
@WebServlet("/updateProduct")
public class UpdateProductServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4062165803456018545L;
	
	ProductService productService=new ProductServiceImpl();
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String id = req.getParameter("id");
		String name = req.getParameter("name");
		String description = req.getParameter("description");
		String count = req.getParameter("count");
		Product product = new Product();
		product.setName(name);
		product.setDescription(description);
		product.setCount(Integer.parseInt(count));
		product.setId(Integer.parseInt(id));
		productService.update(product);
		resp.sendRedirect("main");
	}
}
